<template>
  <v-pagination
    v-model="localPage"
    :length="pageCount"
    @input="onPageChange"
  />
</template>

<script setup>
import { computed, watch, ref } from 'vue'
const props = defineProps({
  page: Number,
  pageSize: Number,
  total: Number
})
const emit = defineEmits(['update:page'])
const localPage = ref(props.page)
watch(() => props.page, val => localPage.value = val)
const pageCount = computed(() => Math.ceil(props.total / props.pageSize))
function onPageChange(val) {
  emit('update:page', val)
}
</script> 